def file_reader(path):
    lines = []
    with open(path, 'r', encoding='utf8') as f:
        while True:
            line = f.readline()
            if not line:
                break
            lines.append(line)
    return lines


def file_reader_generator(path):
    with open(path, 'r', encoding='utf8') as f:
        while True:
            line = f.readline()
            if not line:
                break
            yield line


if __name__ == '__main__':

    def main():
        path = r'D:\_dell7590_root\local\LNP_datasets\med\med_dialog\MedDialog_processed\MedDialog_processed\train_data.json'

        if 0:
            lines = file_reader(path)
            print(''.join(lines[:20]))
        else:
            gen = file_reader_generator(path)
            for i, line in enumerate(gen):
                if i >= 20:
                    break
                print(line)

    main()
